
<?php include_once 'common/header.php';  ?>
<!-- admin_main -->
<div class="admin_main">
	<!-- Admin_top end -->
	<?php include_once 'common/account_left.php';  ?>
	<!-- Admin_Left End -->
	<div class="admin_right">
		<div class="admin_right_title">
		<strong>资金管理</strong> &gt;&gt; 提现列表
		</div>
		<div class="admin_right_con">
			<table border="0" cellspacing="1" cellpadding="0">
			  <tr style="color:#0068b7;">
			  	<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>ID</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>用户名</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>姓名</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>类型</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>帐号</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>提现金额</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>到账金额</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>手续费</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>申请时间</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>审核时间</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>状态</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>明细</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>操作</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1">
			  	<input type="checkbox" name="alldaozhang" id="alldaozhang" />
			  	<input type="button" id="btn_batchdz" value="到账" onclick="batchdz()" />
			  	</td>
			  </tr>
			  <?php foreach($accountcash_list as $key=>$accountcash){?>
			  <tr>
			  	<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $accountcash['id'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><a href="javascript:search('<?php echo $accountcash['username'];?>');"><?php echo $accountcash['username'];?></a></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $accountcash['realname'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $user_loan[$accountcash['is_loan']];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $accountcash['account'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo number_format($accountcash['total'],2);?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo number_format($accountcash['credited'],2);?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo number_format($accountcash['fee'],2);?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo date('m-d H:i', $accountcash['add_time']);?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo date('m-d H:i', $accountcash['verify_time']);?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $account_cash_status[$accountcash['fstatus']];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><a target="_blank" href="/ychadmin/accountlog/accountloglist/?username=<?php echo $accountcash['username'];?>">资金流水</a></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF">
				<?php if($accountcash['fstatus'] == 0){?>
					<a href="javascript:verify(<?php echo $accountcash['id'];?>);">审核</a>	
				<?php }elseif($accountcash['fstatus'] == 1){?>
					<a href="javascript:review(<?php echo $accountcash['id'];?>);">到账</a>
				<?php }?>
				</td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF">
			  	<?php if($accountcash['fstatus'] == 1){?><input type="checkbox" name="daozhang" id="daozhang" value="<?php echo $accountcash['id'];?>"/><?php }?>
			  	</td>
			  </tr>
			  <?php }?>
			  <tr>
			  	<td colspan="17" height="35" align="left" valign="middle" bgcolor="#FFFFFF">
			  		<form action="/ychadmin/accountcash/accountcashlist/" method="get" id="cashForm">
			  			用户名：<input type="text" id="username" name="username" style="width: 100px;" value="<?php echo $username;?>" />
			  			实名：<input type="text" id="realname" name="realname" style="width: 100px;" value="<?php echo $realname;?>" />
			  			类型：<select id="is_loan" name="is_loan">
			  				<option value="-1" <?php if($is_loan==-1){?>selected="selected"<?php }?>>所有</option>
			  				<?php foreach($user_loan as $key=>$value){?>
			  				<option value="<?php echo $key?>" <?php if($is_loan==$key){?>selected="selected"<?php }?>><?php echo $value;?></option>
			  				<?php }?>
			  			</select>
			  			状态：<select id="fstatus" name="fstatus">
			  				<option value="-1" <?php if($fstatus==-1){?>selected="selected"<?php }?>>所有</option>
			  				<?php foreach($account_cash_status as $key=>$value){?>
			  				<option value="<?php echo $key?>" <?php if($fstatus==$key){?>selected="selected"<?php }?>><?php echo $value;?></option>
			  				<?php }?>
			  			</select>
			  			开始时间：<input type="text" id="strtime" name="strtime" style="width: 100px;" value="<?php echo $strtime;?>"  onfocus="WdatePicker()" />
			  			结束时间：<input type="text" id="endtime" name="endtime" style="width: 100px;" value="<?php echo $endtime;?>"  onfocus="WdatePicker()" />
			  			<input type="submit" value="查询" />
			  			<a href="/ychadmin/accountcash/accountcashexcel/?username=<?php echo $username;?>&is_loan=<?php echo $is_loan;?>&fstatus=<?php echo $fstatus;?>&strtime=<?php echo $strtime;?>&endtime=<?php echo $endtime;?>">导出数据</a>
			  		</form>
			  	</td>
			  </tr>
			  <tr>
			  	<td colspan="17"  height="35" align="center" valign="middle" bgcolor="#FFFFFF" class="page"><?php echo $this->pagination->create_links();?>共<?php echo $accountcash_count;?>条记录，总计金额：<?php echo $accountcash_total;?></td>
			  </tr>
			</table>
			</div>
	</div>
<!-- Admin_Right End -->
</div>
<!-- admin_main end -->
<script type="text/javascript">
$("#alldaozhang").click(function(){
   $("input[name='daozhang']").prop("checked",$(this).prop("checked"));
});
function search(username){
	$("#username").val(username);
	$("#cashForm").submit();
}
function batchdz(){
	$("#btn_batchdz").attr('disabled',true);
	//alert($("input[name='daozhang'][checked]").val());
	var chk_value = [];    
    $('input[name="daozhang"]:checked').each(function(){    
     	chk_value.push($(this).val());    
    });
    $( "#dialog5" ).dialog({
		width:400,
		modal:true, //蒙层（弹出会影响页面大小）
		title:'提现到账审核', 
		buttons:{"确定":function(){$(this).dialog("close");}},
		close: function() {
			location.reload();
		}
	});
    $( "#msg5" ).html('批量审核中...');
    $.ajax({
		type: "POST",
		url: "/ychadmin/accountcash/batchreview",
		data: "ids="+chk_value,
		success: function(msg){
	        if(msg == 1){
	        	//alert("批量审核通过");
	        	$( "#msg5" ).html('批量审核通过');
	        }else{
	        	$( "#msg5" ).html('批量审核失败');
	        	//alert("批量审核失败");
		    }
		},
		dataType: "text"
	});
}
</script>
<div id="dialog" title="系统提示" style="display:none;">
<div id="msg" style="text-align:center;color:red">&nbsp;</div>
<input type="hidden" name="id" id="id" />
总金额：<span id="account_total"></span> 可用：<span id="account_use"></span><br />
冻结：<span id="account_nouse"></span> 待收：<span id="account_coll"></span><br />
状态： <input type="radio" name="fstatus" id="fstatus" value="2" checked="checked"/>审核不通过 <br /><br />
备注：<textarea  id="verify_remark" name="verify_remark" style="width: 300px;height: 100px;">审核不通过</textarea><br />
</div>
<script>
function verify(id){
	if(id>0){
		$.ajax({
			type: "GET",
			url: "/ychadmin/account/jsinfo/"+id,
			data: "",
			success: function(data){
				$( "#dialog" ).dialog({
					width:400,
					modal:true, //蒙层（弹出会影响页面大小）
					title:'提现审核', 
					buttons:{"提交":function(){verifysub();},"关闭":function(){$(this).dialog("close");}}
				});
				$("#id").val(id);
				$("#account_total").html(data.total);
				$("#account_use").html(data.use_money);
				$("#account_nouse").html(data.no_use_money);
				$("#account_coll").html(data.collection);
			},
			dataType: "json"
		});
	}
}

function verifysub(){
	$( "#dialog" ).dialog({
		width:400,
		modal:true, //蒙层（弹出会影响页面大小）
		title:'提现审核',
		buttons:{"提交":function(){},"关闭":function(){}}
	});
	if($('#verify_remark').val() == ''){
		$("#msg").html("请填写备注");
		return false;
	}
	$("#msg").html('提交中...');
	$.ajax({
			type: "POST",
			url: "/ychadmin/accountcash/verify",
			data: "id="+$('#id').val()+"&fstatus="+$('input:radio[name="fstatus"]:checked').val()+"&verify_remark="+$('#verify_remark').val(),
			success: function(msg){
		        $("#msg").html(msg);
				setTimeout(function(){
						location.reload();
				},3000);
			},
			dataType: "text"
		});
}


</script>

<div id="dialog1" title="系统提示" style="display:none;">
<div id="msg1" style="text-align:center;color:red">&nbsp;</div>
<input type="hidden" name="id" id="id" />
状态： <input type="radio" name="fstatus1" id="fstatus1" value="2" checked="checked"/>审核不通过 <br /><br />
备注：<textarea  id="review_remark" name="review_remark" style="width: 300px;height: 100px;">审核不通过</textarea><br />
</div>
<script>
function review(id){
	if(id>0){
		$( "#dialog1" ).dialog({
			width:400,
			modal:true, //蒙层（弹出会影响页面大小）
			title:'到账审核', 
			buttons:{"提交":function(){reviewsub();},"关闭":function(){$(this).dialog("close");}},
		});
		$("#id").val(id);
	}
}

function reviewsub(){
	$( "#dialog1" ).dialog({
		width:400,
		modal:true, //蒙层（弹出会影响页面大小）
		title:'提现审核',
		buttons:{"提交":function(){},"关闭":function(){}}
	});
	if($('#review_remark').val() == ''){
		$("#msg1").html("请填写备注");
		return false;
	}
	$("#msg1").html('提交中...');
	$.ajax({
			type: "POST",
			url: "/ychadmin/accountcash/review",
			data: "id="+$('#id').val()+"&fstatus="+$('input:radio[name="fstatus1"]:checked').val()+"&review_remark="+$('#review_remark').val(),
			success: function(msg){
		        $( "#dialog1" ).dialog();
		        if(msg=='1'){
		        	$("#msg1").html("操作成功");
		        }else{
		        	$("#msg1").html("操作失败，请联系管理员。");
			    }
				setTimeout(function(){
						location.reload();
				},3000);
			},
			dataType: "text"
		});
}


</script>

<div id="dialog5" title="系统提示" style="display:none;">
<div id="msg5" style="text-align:center;color:red">&nbsp;</div>
</div>
</body>
</html>
